package rentalstore;

import java.util.Enumeration;
import java.util.Vector;

/**
 * DefaultStatement
 *
 * @author Burgess Li
 * @createDate 2018/08/28 0:00
 */
public class DefaultStatement extends Statement {

    @Override
    protected String buildType() {
        return "DEFAULT_STATEMENT";
    }

    String generateHeader(String title) {
        return "Rental Record for " + title + "\n";
    }

    String generateDetails(Vector rentals) {
        StringBuilder result = new StringBuilder();
        Enumeration rentalsEnumeration = rentals.elements();
        while(rentalsEnumeration.hasMoreElements()){
            Rental each = (Rental) rentalsEnumeration.nextElement();
            //show figures for this rental
            result.append("\t" + each.getMovie().getTitle() + "\t" + String.valueOf(each.computeAmount()) + "\n");
        }
        return result.toString();
    }

    String generateFooter(double totalAmount, double totalFrequentRenterPoints) {
        String result = "Amount owed is" + String.valueOf(totalAmount) + "\n";
        result += "You earned" + String.valueOf(totalFrequentRenterPoints) + " frequent renter points";
        return result;
    }

}
